'use strict';
Object.defineProperties(exports, {
  __esModule: { value: !0 },
  [Symbol.toStringTag]: { value: 'Module' },
});
const m = require('./name.cjs'),
  U = '[-\\+]?\\d+%?',
  L = '[-\\+]?\\d*\\.\\d+%?',
  c = '(?:' + L + ')|(?:' + U + ')',
  x = '[\\s|\\(]+(' + c + ')[,|\\s]+(' + c + ')[,|\\s]+(' + c + ')\\s*\\)?',
  A =
    '[\\s|\\(]+(' +
    c +
    ')[,|\\s]+(' +
    c +
    ')[,|\\s]+(' +
    c +
    ')[,|\\s]+(' +
    c +
    ')\\s*\\)?',
  b = {
    CSS_UNIT: new RegExp(c),
    rgb: new RegExp('rgb' + x),
    rgba: new RegExp('rgba' + A),
    hsl: new RegExp('hsl' + x),
    hsla: new RegExp('hsla' + A),
    hsv: new RegExp('hsv' + x),
    hsva: new RegExp('hsva' + A),
    hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
    hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
    hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
    hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
  };
function h(t, r) {
  if ((t || (t = ''), r || (r = {}), t instanceof h)) return t;
  if (!(this instanceof h)) return new h(t, r);
  let e = w(t);
  (this._originalInput = t),
    (this._r = e.r),
    (this._g = e.g),
    (this._b = e.b),
    (this._a = e.a),
    (this._roundA = Math.round(100 * this._a) / 100),
    (this._format = r.format || e.format),
    (this._gradientType = r.gradientType),
    this._r < 1 && (this._r = Math.round(this._r)),
    this._g < 1 && (this._g = Math.round(this._g)),
    this._b < 1 && (this._b = Math.round(this._b)),
    (this._ok = e.ok);
}
h.prototype = {
  isDark() {
    return this.getBrightness() < 128;
  },
  isLight() {
    return !this.isDark();
  },
  isValid() {
    return this._ok;
  },
  getOriginalInput() {
    return this._originalInput;
  },
  getFormat() {
    return this._format;
  },
  getAlpha() {
    return this._a;
  },
  getBrightness() {
    let t = this.toRgb();
    return (t.r * 299 + t.g * 587 + t.b * 114) / 1e3;
  },
  getLuminance() {
    let t = this.toRgb(),
      r,
      e,
      i,
      a,
      n,
      s;
    return (
      (r = t.r / 255),
      (e = t.g / 255),
      (i = t.b / 255),
      r <= 0.03928 ? (a = r / 12.92) : (a = Math.pow((r + 0.055) / 1.055, 2.4)),
      e <= 0.03928 ? (n = e / 12.92) : (n = Math.pow((e + 0.055) / 1.055, 2.4)),
      i <= 0.03928 ? (s = i / 12.92) : (s = Math.pow((i + 0.055) / 1.055, 2.4)),
      0.2126 * a + 0.7152 * n + 0.0722 * s
    );
  },
  setAlpha(t) {
    return (
      (this._a = F(t)), (this._roundA = Math.round(100 * this._a) / 100), this
    );
  },
  toHsv() {
    let t = y(this._r, this._g, this._b);
    return { h: t.h * 360, s: t.s, v: t.v, a: this._a };
  },
  toHsvString() {
    let t = y(this._r, this._g, this._b),
      r = Math.round(t.h * 360),
      e = Math.round(t.s * 100),
      i = Math.round(t.v * 100);
    return this._a == 1
      ? 'hsv(' + r + ', ' + e + '%, ' + i + '%)'
      : 'hsva(' + r + ', ' + e + '%, ' + i + '%, ' + this._roundA + ')';
  },
  toHsl() {
    let t = S(this._r, this._g, this._b);
    return { h: t.h * 360, s: t.s, l: t.l, a: this._a };
  },
  toHslString() {
    let t = S(this._r, this._g, this._b),
      r = Math.round(t.h * 360),
      e = Math.round(t.s * 100),
      i = Math.round(t.l * 100);
    return this._a == 1
      ? 'hsl(' + r + ', ' + e + '%, ' + i + '%)'
      : 'hsla(' + r + ', ' + e + '%, ' + i + '%, ' + this._roundA + ')';
  },
  toHex(t) {
    return H(this._r, this._g, this._b, t);
  },
  toHexString(t) {
    return '#' + this.toHex(t);
  },
  toHex8(t) {
    return E(this._r, this._g, this._b, this._a, t);
  },
  toHex8String(t) {
    return '#' + this.toHex8(t);
  },
  toRgb() {
    return {
      r: Math.round(this._r),
      g: Math.round(this._g),
      b: Math.round(this._b),
      a: this._a,
    };
  },
  toRgbArray() {
    return [Math.round(this._r), Math.round(this._g), Math.round(this._b)];
  },
  toRgbString() {
    return this._a == 1
      ? 'rgb(' +
          Math.round(this._r) +
          ', ' +
          Math.round(this._g) +
          ', ' +
          Math.round(this._b) +
          ')'
      : 'rgba(' +
          Math.round(this._r) +
          ', ' +
          Math.round(this._g) +
          ', ' +
          Math.round(this._b) +
          ', ' +
          this._roundA +
          ')';
  },
  toPercentageRgb() {
    return {
      r: Math.round(u(this._r, 255) * 100) + '%',
      g: Math.round(u(this._g, 255) * 100) + '%',
      b: Math.round(u(this._b, 255) * 100) + '%',
      a: this._a,
    };
  },
  toPercentageRgbString() {
    return this._a == 1
      ? 'rgb(' +
          Math.round(u(this._r, 255) * 100) +
          '%, ' +
          Math.round(u(this._g, 255) * 100) +
          '%, ' +
          Math.round(u(this._b, 255) * 100) +
          '%)'
      : 'rgba(' +
          Math.round(u(this._r, 255) * 100) +
          '%, ' +
          Math.round(u(this._g, 255) * 100) +
          '%, ' +
          Math.round(u(this._b, 255) * 100) +
          '%, ' +
          this._roundA +
          ')';
  },
  toName() {
    return this._a === 0
      ? 'transparent'
      : this._a < 1
        ? !1
        : et[H(this._r, this._g, this._b, !0)] || !1;
  },
  toFilter(t) {
    let r = '#' + R(this._r, this._g, this._b, this._a),
      e = r,
      i = this._gradientType ? 'GradientType = 1, ' : '';
    if (t) {
      let a = h(t);
      e = '#' + R(a._r, a._g, a._b, a._a);
    }
    return (
      'progid:DXImageTransform.Microsoft.gradient(' +
      i +
      'startColorstr=' +
      r +
      ',endColorstr=' +
      e +
      ')'
    );
  },
  toString(t) {
    let r = !!t;
    t = t || this._format;
    let e = !1,
      i = this._a < 1 && this._a >= 0;
    return !r &&
      i &&
      (t === 'hex' ||
        t === 'hex6' ||
        t === 'hex3' ||
        t === 'hex4' ||
        t === 'hex8' ||
        t === 'name')
      ? t === 'name' && this._a === 0
        ? this.toName()
        : this.toRgbString()
      : (t === 'rgb' && (e = this.toRgbString()),
        t === 'prgb' && (e = this.toPercentageRgbString()),
        (t === 'hex' || t === 'hex6') && (e = this.toHexString()),
        t === 'hex3' && (e = this.toHexString(!0)),
        t === 'hex4' && (e = this.toHex8String(!0)),
        t === 'hex8' && (e = this.toHex8String()),
        t === 'name' && (e = this.toName()),
        t === 'hsl' && (e = this.toHslString()),
        t === 'hsv' && (e = this.toHsvString()),
        e || this.toHexString());
  },
  clone() {
    return h(this.toString());
  },
  _applyModification(t, r) {
    let e = t.apply(null, [this].concat([].slice.call(r)));
    return (
      (this._r = e._r),
      (this._g = e._g),
      (this._b = e._b),
      this.setAlpha(e._a),
      this
    );
  },
  lighten() {
    return this._applyModification(W, arguments);
  },
  brighten() {
    return this._applyModification(Z, arguments);
  },
  darken() {
    return this._applyModification(X, arguments);
  },
  desaturate() {
    return this._applyModification(V, arguments);
  },
  saturate() {
    return this._applyModification($, arguments);
  },
  greyscale() {
    return this._applyModification(q, arguments);
  },
  spin() {
    return this._applyModification(J, arguments);
  },
  _applyCombination(t, r) {
    return t.apply(null, [this].concat([].slice.call(r)));
  },
  analogous() {
    return this._applyCombination(Y, arguments);
  },
  complement() {
    return this._applyCombination(K, arguments);
  },
  monochromatic() {
    return this._applyCombination(tt, arguments);
  },
  splitcomplement() {
    return this._applyCombination(Q, arguments);
  },
  triad() {
    return this._applyCombination(v, [3]);
  },
  tetrad() {
    return this._applyCombination(v, [4]);
  },
};
h.fromRatio = function (t, r) {
  if (typeof t == 'object') {
    let e = {};
    for (let i in t)
      Object.prototype.hasOwnProperty.call(t, i) &&
        (i === 'a' ? (e[i] = t[i]) : (e[i] = p(t[i])));
    t = e;
  }
  return h(t, r);
};
function w(t) {
  let r = { r: 0, g: 0, b: 0 },
    e = 1,
    i = null,
    a = null,
    n = null,
    s = !1,
    l = !1;
  return (
    typeof t == 'string' && (t = G(t)),
    typeof t == 'object' &&
      (d(t.r) && d(t.g) && d(t.b)
        ? ((r = k(t.r, t.g, t.b)),
          (s = !0),
          (l = String(t.r).at(-1) === '%' ? 'prgb' : 'rgb'))
        : d(t.h) && d(t.s) && d(t.v)
          ? ((i = p(t.s)),
            (a = p(t.v)),
            (r = I(t.h, i, a)),
            (s = !0),
            (l = 'hsv'))
          : d(t.h) &&
            d(t.s) &&
            d(t.l) &&
            ((i = p(t.s)),
            (n = p(t.l)),
            (r = P(t.h, i, n)),
            (s = !0),
            (l = 'hsl')),
      Object.prototype.hasOwnProperty.call(t, 'a') && (e = t.a)),
    (e = F(e)),
    {
      ok: s,
      format: t.format || l,
      r: Math.min(255, Math.max(r.r, 0)),
      g: Math.min(255, Math.max(r.g, 0)),
      b: Math.min(255, Math.max(r.b, 0)),
      a: e,
    }
  );
}
function k(t, r, e) {
  return { r: u(t, 255) * 255, g: u(r, 255) * 255, b: u(e, 255) * 255 };
}
function S(t, r, e) {
  (t = u(t, 255)), (r = u(r, 255)), (e = u(e, 255));
  let i = Math.max(t, r, e),
    a = Math.min(t, r, e),
    n,
    s,
    l = (i + a) / 2;
  if (i == a) n = s = 0;
  else {
    let o = i - a;
    switch (((s = l > 0.5 ? o / (2 - i - a) : o / (i + a)), i)) {
      case t:
        n = (r - e) / o + (r < e ? 6 : 0);
        break;
      case r:
        n = (e - t) / o + 2;
        break;
      case e:
        n = (t - r) / o + 4;
        break;
    }
    n /= 6;
  }
  return { h: n, s, l };
}
function P(t, r, e) {
  let i, a, n;
  (t = u(t, 360)), (r = u(r, 100)), (e = u(e, 100));
  function s(l, o, g) {
    return (
      g < 0 && (g += 1),
      g > 1 && (g -= 1),
      g < 1 / 6
        ? l + (o - l) * 6 * g
        : g < 1 / 2
          ? o
          : g < 2 / 3
            ? l + (o - l) * (2 / 3 - g) * 6
            : l
    );
  }
  if (r === 0) i = a = n = e;
  else {
    let l = e < 0.5 ? e * (1 + r) : e + r - e * r,
      o = 2 * e - l;
    (i = s(o, l, t + 1 / 3)), (a = s(o, l, t)), (n = s(o, l, t - 1 / 3));
  }
  return { r: i * 255, g: a * 255, b: n * 255 };
}
function y(t, r, e) {
  (t = u(t, 255)), (r = u(r, 255)), (e = u(e, 255));
  let i = Math.max(t, r, e),
    a = Math.min(t, r, e),
    n = i - a,
    s = 0,
    l = i === 0 ? 0 : n / i,
    o = i;
  if (i == a) s = 0;
  else {
    switch (i) {
      case t:
        s = (r - e) / n + (r < e ? 6 : 0);
        break;
      case r:
        s = (e - t) / n + 2;
        break;
      case e:
        s = (t - r) / n + 4;
        break;
    }
    s /= 6;
  }
  return { h: s, s: l, v: o };
}
function I(t, r, e) {
  (t = u(t, 360) * 6), (r = u(r, 100)), (e = u(e, 100));
  let i = Math.floor(t),
    a = t - i,
    n = e * (1 - r),
    s = e * (1 - a * r),
    l = e * (1 - (1 - a) * r),
    o = i % 6,
    g = [e, s, n, n, l, e][o],
    z = [l, e, e, s, n, n][o],
    D = [n, n, l, e, e, s][o];
  return { r: g * 255, g: z * 255, b: D * 255 };
}
function H(t, r, e, i) {
  let a = [
    _(Math.round(t).toString(16)),
    _(Math.round(r).toString(16)),
    _(Math.round(e).toString(16)),
  ];
  return i &&
    a[0].charAt(0) == a[0].charAt(1) &&
    a[1].charAt(0) == a[1].charAt(1) &&
    a[2].charAt(0) == a[2].charAt(1)
    ? a[0].charAt(0) + a[1].charAt(0) + a[2].charAt(0)
    : a.join('');
}
function E(t, r, e, i, a) {
  let n = [
    _(Math.round(t).toString(16)),
    _(Math.round(r).toString(16)),
    _(Math.round(e).toString(16)),
    _(C(i)),
  ];
  return a &&
    n[0].charAt(0) == n[0].charAt(1) &&
    n[1].charAt(0) == n[1].charAt(1) &&
    n[2].charAt(0) == n[2].charAt(1) &&
    n[3].charAt(0) == n[3].charAt(1)
    ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) + n[3].charAt(0)
    : n.join('');
}
function R(t, r, e, i) {
  return [
    _(C(i)),
    _(Math.round(t).toString(16)),
    _(Math.round(r).toString(16)),
    _(Math.round(e).toString(16)),
  ].join('');
}
h.equals = function (t, r) {
  return !t || !r ? !1 : h(t).toRgbString() == h(r).toRgbString();
};
h.random = function () {
  return h.fromRatio({ r: Math.random(), g: Math.random(), b: Math.random() });
};
function V(t, r) {
  r = r === 0 ? 0 : r || 10;
  let e = h(t).toHsl();
  return (e.s -= r / 100), (e.s = M(e.s)), h(e);
}
function $(t, r) {
  r = r === 0 ? 0 : r || 10;
  let e = h(t).toHsl();
  return (e.s += r / 100), (e.s = M(e.s)), h(e);
}
function q(t) {
  return h(t).desaturate(100);
}
function W(t, r) {
  r = r === 0 ? 0 : r || 10;
  let e = h(t).toHsl();
  return (e.l += r / 100), (e.l = M(e.l)), h(e);
}
function Z(t, r) {
  r = r === 0 ? 0 : r || 10;
  let e = h(t).toRgb();
  return (
    (e.r = Math.max(0, Math.min(255, e.r - Math.round(255 * -(r / 100))))),
    (e.g = Math.max(0, Math.min(255, e.g - Math.round(255 * -(r / 100))))),
    (e.b = Math.max(0, Math.min(255, e.b - Math.round(255 * -(r / 100))))),
    h(e)
  );
}
function X(t, r) {
  r = r === 0 ? 0 : r || 10;
  let e = h(t).toHsl();
  return (e.l -= r / 100), (e.l = M(e.l)), h(e);
}
function J(t, r) {
  let e = h(t).toHsl(),
    i = (e.h + r) % 360;
  return (e.h = i < 0 ? 360 + i : i), h(e);
}
function K(t) {
  let r = h(t).toHsl();
  return (r.h = (r.h + 180) % 360), h(r);
}
function v(t, r) {
  if (isNaN(r) || r <= 0)
    throw new Error('Argument to polyad must be a positive number');
  let e = h(t).toHsl(),
    i = [h(t)],
    a = 360 / r;
  for (let n = 1; n < r; n++)
    i.push(h({ h: (e.h + n * a) % 360, s: e.s, l: e.l }));
  return i;
}
function Q(t) {
  let r = h(t).toHsl(),
    e = r.h;
  return [
    h(t),
    h({ h: (e + 72) % 360, s: r.s, l: r.l }),
    h({ h: (e + 216) % 360, s: r.s, l: r.l }),
  ];
}
function Y(t, r, e) {
  (r = r || 6), (e = e || 30);
  let i = h(t).toHsl(),
    a = 360 / e,
    n = [h(t)];
  for (i.h = (i.h - ((a * r) >> 1) + 720) % 360; --r; )
    (i.h = (i.h + a) % 360), n.push(h(i));
  return n;
}
function tt(t, r) {
  r = r || 6;
  let e = h(t).toHsv(),
    i = e.h,
    a = e.s,
    n = e.v,
    s = [],
    l = 1 / r;
  for (; r--; ) s.push(h({ h: i, s: a, v: n })), (n = (n + l) % 1);
  return s;
}
h.mix = function (t, r, e) {
  e = e === 0 ? 0 : e || 50;
  let i = h(t).toRgb(),
    a = h(r).toRgb(),
    n = e / 100,
    s = {
      r: (a.r - i.r) * n + i.r,
      g: (a.g - i.g) * n + i.g,
      b: (a.b - i.b) * n + i.b,
      a: (a.a - i.a) * n + i.a,
    };
  return h(s);
};
h.readability = function (t, r) {
  let e = h(t),
    i = h(r);
  return (
    (Math.max(e.getLuminance(), i.getLuminance()) + 0.05) /
    (Math.min(e.getLuminance(), i.getLuminance()) + 0.05)
  );
};
h.isReadable = function (t, r, e) {
  let i = h.readability(t, r),
    a,
    n;
  switch (((n = !1), (a = B(e)), a.level + a.size)) {
    case 'AAsmall':
    case 'AAAlarge':
      n = i >= 4.5;
      break;
    case 'AAlarge':
      n = i >= 3;
      break;
    case 'AAAsmall':
      n = i >= 7;
      break;
  }
  return n;
};
h.mostReadable = function (t, r, e) {
  let i = null,
    a = 0,
    n,
    s,
    l,
    o;
  (e = e || {}), (s = e.includeFallbackColors), (l = e.level), (o = e.size);
  for (let g = 0; g < r.length; g++)
    (n = h.readability(t, r[g])), n > a && ((a = n), (i = h(r[g])));
  return h.isReadable(t, i, { level: l, size: o }) || !s
    ? i
    : ((e.includeFallbackColors = !1), h.mostReadable(t, ['#fff', '#000'], e));
};
h.names = m.default;
let et = (h.hexNames = N(m.default));
function N(t) {
  let r = {};
  for (let e in t) Object.prototype.hasOwnProperty.call(t, e) && (r[t[e]] = e);
  return r;
}
function F(t) {
  return (t = parseFloat(t)), (isNaN(t) || t < 0 || t > 1) && (t = 1), t;
}
function u(t, r) {
  O(t) && (t = '100%');
  let e = j(t);
  return (
    (t = Math.min(r, Math.max(0, parseFloat(t)))),
    e && (t = parseInt(t * r, 10) / 100),
    Math.abs(t - r) < 1e-6 ? 1 : (t % r) / parseFloat(r)
  );
}
function M(t) {
  return Math.min(1, Math.max(0, t));
}
function f(t) {
  return parseInt(t, 16);
}
function O(t) {
  return typeof t == 'string' && t.indexOf('.') != -1 && parseFloat(t) === 1;
}
function j(t) {
  return typeof t == 'string' && t.indexOf('%') != -1;
}
function _(t) {
  return t.length == 1 ? '0' + t : '' + t;
}
function p(t) {
  return t <= 1 && (t = t * 100 + '%'), t;
}
function C(t) {
  return Math.round(parseFloat(t) * 255).toString(16);
}
function T(t) {
  return f(t) / 255;
}
function d(t) {
  return !!b.CSS_UNIT.exec(t);
}
function G(t) {
  t = t.trim().toLowerCase();
  let r = !1;
  if (m.default[t]) (t = m.default[t]), (r = !0);
  else if (t == 'transparent')
    return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
  let e;
  return (e = b.rgb.exec(t))
    ? { r: e[1], g: e[2], b: e[3] }
    : (e = b.rgba.exec(t))
      ? { r: e[1], g: e[2], b: e[3], a: e[4] }
      : (e = b.hsl.exec(t))
        ? { h: e[1], s: e[2], l: e[3] }
        : (e = b.hsla.exec(t))
          ? { h: e[1], s: e[2], l: e[3], a: e[4] }
          : (e = b.hsv.exec(t))
            ? { h: e[1], s: e[2], v: e[3] }
            : (e = b.hsva.exec(t))
              ? { h: e[1], s: e[2], v: e[3], a: e[4] }
              : (e = b.hex8.exec(t))
                ? {
                    r: f(e[1]),
                    g: f(e[2]),
                    b: f(e[3]),
                    a: T(e[4]),
                    format: r ? 'name' : 'hex8',
                  }
                : (e = b.hex6.exec(t))
                  ? {
                      r: f(e[1]),
                      g: f(e[2]),
                      b: f(e[3]),
                      format: r ? 'name' : 'hex',
                    }
                  : (e = b.hex4.exec(t))
                    ? {
                        r: f(e[1] + '' + e[1]),
                        g: f(e[2] + '' + e[2]),
                        b: f(e[3] + '' + e[3]),
                        a: T(e[4] + '' + e[4]),
                        format: r ? 'name' : 'hex8',
                      }
                    : (e = b.hex3.exec(t))
                      ? {
                          r: f(e[1] + '' + e[1]),
                          g: f(e[2] + '' + e[2]),
                          b: f(e[3] + '' + e[3]),
                          format: r ? 'name' : 'hex',
                        }
                      : !1;
}
function B(t) {
  let r, e;
  return (
    (t = t || { level: 'AA', size: 'small' }),
    (r = (t.level || 'AA').toUpperCase()),
    (e = (t.size || 'small').toLowerCase()),
    r !== 'AA' && r !== 'AAA' && (r = 'AA'),
    e !== 'small' && e !== 'large' && (e = 'small'),
    { level: r, size: e }
  );
}
exports.bound01 = u;
exports.boundAlpha = F;
exports.clamp01 = M;
exports.convertDecimalToHex = C;
exports.convertHexToDecimal = T;
exports.convertToPercentage = p;
exports.default = h;
exports.flip = N;
exports.hslToRgb = P;
exports.hsvToRgb = I;
exports.inputToRGB = w;
exports.isOnePointZero = O;
exports.isPercentage = j;
exports.isValidCSSUnit = d;
exports.pad2 = _;
exports.parseIntFromHex = f;
exports.polyad = v;
exports.rgbToHex = H;
exports.rgbToHsl = S;
exports.rgbToHsv = y;
exports.rgbToRgb = k;
exports.rgbaToArgbHex = R;
exports.rgbaToHex = E;
exports.stringInputToObject = G;
exports.validateWCAG2Parms = B;
